package review;

import java.util.Scanner;

public class Demo1 {

}

class BankAccount1 {
    int id;
    double money;
    public BankAccount1(int id, double money) {
        this.id = id;
        this.money = money;
    }
    public void deposit(double amount) {
        money += amount;
    }
    public void withdraw(double amount) {
        money -= amount;
    }
    public double GetMoney() {
        return this.money;
    }
}

class customer {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BankAccount1 ba = new BankAccount1(5, 100);
        System.out.println("请输存入金额:");
        double savings = sc.nextDouble();
        try {
            if (savings >= 0) {
                ba.deposit(savings);
            } else {
                throw new Money1("存入金额小于0");
            }
        }
        catch (Money1 money1) {
            System.err.println(money1.getMessage());
        }
        System.out.println("请输取出金额:");
        double GetMoney = sc.nextDouble();
        try {
            if (GetMoney <= ba.GetMoney()) {
                ba.withdraw(GetMoney);
            } else {
                throw new Money1("存款不足");
            }
        }
        catch (Money1 money1) {
            System.err.println(money1.getMessage());
        }
    }
}

class Money1 extends RuntimeException{
    public Money1(String message) {
        super(message);
    }
}